<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<!DOCTYPE html>
<html lang="zh-CN"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<meta charset="UTF-8">
	<title>凯盛项目管理系统</title>
	<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap.js"></script>
</head>
	<jsp:include page="include/head.jsp">
		<jsp:param value="${ep}" name="ep"/>
	</jsp:include>
	
	<body class="body">
	
	
  <div class="navbar">
    
  </div>
		
		<div class="row">
			<div class="span9 offset3">
	        	<form class="form-horizontal" action="employee.jspx" id="myform" method="post">
			       <fieldset>
			        <legend>注册新用户</legend>
			        <div class="control-group">
			           <label class="control-label" for="input01">用户名</label>
			           <div class="controls">
			             <input type="text" class="span4" id="name" x-webkit-speech="undefined" name="name">
			              <span id="name_erro"></span>
			            </div>
			          </div>
			          <div class="control-group">
			            <label class="control-label" for="input01">密码</label>
			            <div class="controls">
			              <input   type="password" class="span4"  x-webkit-speech="undefined"  id="password" name="password"/>
						  <span  id="password_erro"></span>	
			            </div>
			          </div>
			           <div class="control-group">
			            <label class="control-label" for="input01">email</label>
			            <div class="controls">
			              <input class="span4"  x-webkit-speech="undefined"  id="email" name="email"/>
						  <p class="help-block" id="email_error"></p>	
			            </div>
			          </div>
			          <div class="control-group">
			            <label class="control-label" for="input01">地址</label>
			            <div class="controls">
			              <input class="span4"  x-webkit-speech="undefined"  id="adress" name="adress"/>
						  <p class="help-block" id="adress_error"></p>	
			            </div>
			          </div>
			          <div class="control-group">
			            <label class="control-label" for="input01">电话号码</label>
			            <div class="controls">
			              <input class="span4"  x-webkit-speech="undefined"  id="tel" name="tel"/>
						  <p class="help-block" id="tel_error"></p>	
			            </div>
			          </div>
			          <div class="control-group">
			            <label class="control-label" for="input01">职位</label>
			            <div class="controls">
			              <input class="span4"  x-webkit-speech="undefined"  id="zhiwei" name="zhiwei"/>
						  <p class="help-block" id="zhiwei_error"></p>	
			            </div>
			          </div>
			          
			           <div class="span3">
						</div>
			          
			          <div class="form-actions">
			            <button type="button" id="btn" class="btn btn-primary">保存</button>
			            <button class="btn" onclick="location.back()">返回</button>
			          </div>
			        </fieldset>
			
			      </form>          

	        	
			</div>
			<div class="span3" width:200px;height:200px>
				<div class="well" style="width:100px;height:100px;">
					<img src="img/1.jpg" alt="暂无头像" style="width:100px;height:100px;"/>
					
					<div>
					<form action="file.jspx" method="post" style="margin-top:30px;">
						<input type="file" name="picture"/>
						<input type="submit" value="上传头像" />
					</form>
					</div>
				</div>
			</div>
		</div>
	<script type="text/javascript">
		var xmlHttp;
    	
    	function createXMlHttpRequest() {
    		if(window.ActiveXObject) {
        		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        	} else {
        		xmlHttp = new XMLHttpRequest();
        	}
    	}
    	function callback() {
    		if(xmlHttp.readyState == 4) {
    			if(xmlHttp.status == 200) {
    				var value = xmlHttp.responseText;
    				if(value == "yes") {
    					$("#name_erro").html("X");
    					return;
    				} else {
    					$("#name_erro").html("√");
    				}
    			} else {
    				//alert("服务器暂时不可用，请稍后再试" + xmlHttp.status);
    			}
    		} else {
    			//loading
    			$("#name_erro").html("验证中...");
    		}
    	}
    	
	
		$(document).ready(function(){
			$("#name").blur(function(){
				var name=$("#name").val();
				createXMlHttpRequest();
				xmlHttp.open("post", "employee.jspx?m=ajax", true);
	    		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    		xmlHttp.onreadystatechange = callback;
	    		xmlHttp.send("name="+name);
			});
		
			$("#name").keydown(function(){
				$("#name_erro").html("");
			});
			$("#password").keydown(function(){
				$("#password_erro").html("");
			});
			$("#btn").click(function(){
				var name=$("#name").val();
				var pwd=$("#password").val();
				
				if(name.trim()==""){
					$("#name").focus();
					$("#name_erro").html("（用户名必填！）");
					return;
				}
				
				if(pwd==""){
					$("#password").focus();
					$("#password_erro").html("（密码必填！）");
					return;
				}
				var v = /^(\d|\w){6,10}$/;
				if(!v.test(pwd)){
					$("#password").focus();
					$("#password_erro").html("密码格式错误！）");
					return;
				}
				$("#myform").submit();
			});
		
		});
	</script>
	</body>
</html>












	